package com.qianbei.user;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.qianbei.R;
import com.qianbei.common.base.BaseActivity;
import com.qianbei.common.init.SetData;
import com.qianbei.common.web.WebActivity;
import com.qianbei.user.privacy.AboutActivity;
import com.qianbei.user.privacy.PrivacyActivity;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * 相关问题页面
 *
 * @author  jiaowenzheng
 * Created by user on 16/5/10.
 */
public class OtherActivity extends BaseActivity {

    private ListView mListView;
    private OtherListAdapter mAdapter;

    private List<Integer> itemList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_other_layout);

        setTitle(R.string.help_question);

        itemList = new ArrayList<>();

        if (!TextUtils.isEmpty(SetData.getUserID())){
            itemList.add(R.string.blackboard);
            itemList.add(R.string.help);
            itemList.add(R.string.other_private);
            itemList.add(R.string.online_service);
        }else{
            itemList.add(R.string.help);
            itemList.add(R.string.other_private);
        }

        itemList.add(R.string.about);

        mListView = (ListView) findViewById(R.id.other_list_view);
        mAdapter = new OtherListAdapter(this,itemList,R.layout.item_other_list);
        mListView.setAdapter(mAdapter);

        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                switch (itemList.get(position)){

                    case R.string.blackboard:       //黑板报
                        WebActivity.startWebActivity(mContext,BLACK_BOARD_URL);
                        break;
                    case R.string.help:             //使用帮助
                        WebActivity.startWebActivity(mContext,USAGE_HELP_URL);
                        break;
                    case R.string.other_private:    //隐私声明
                        jump(PrivacyActivity.class);
                        break;
                    case R.string.online_service:   //在线客服
                        WebActivity.startWebActivity(mContext,  ONLINE_SERVICE_URL);
                        break;
                    case R.string.about:            //关于我们
                        jump(AboutActivity.class);
                        break;
                }
            }
        });
    }

}
